﻿namespace UFIDA.U9.Learn.ItemBP
{
	using System;
	using System.Collections.Generic;
	using System.Text;
    using UFIDA.U9.CBO.QC.QCSchema;
    using UFSoft.UBF.AopFrame;	
	using UFSoft.UBF.Util.Context;

	/// <summary>
	/// QCSchemaQuery partial 
	/// </summary>	
	public partial class QCSchemaQuery 
	{	
		internal BaseStrategy Select()
		{
			return new QCSchemaQueryImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class QCSchemaQueryImpementStrategy : BaseStrategy
	{
		public QCSchemaQueryImpementStrategy() { }

		public override object Do(object obj)
		{						
			QCSchemaQuery bpObj = (QCSchemaQuery)obj;

			if (bpObj.QCGuideLineID == 0)
				throw new Exception("传入参数为0");
            QCSchema.EntityList entityList = QCSchema.Finder.FindAll("1=1", null);
			if (entityList == null || entityList.Count == 0)
				throw new Exception("查询数据为空");

			List<QCSchemaDTO> retlist = new List<QCSchemaDTO>();
			foreach(var entity in entityList)
            {
				QCSchemaDTO dto = new QCSchemaDTO();
				dto.ID = entity.ID;
				dto.Code = entity.Code;
				dto.Name = entity.QCSchemaHead.Name;
				dto.Version = entity.Version;
				retlist.Add(dto);
            }
			return retlist;
        }
    }

	#endregion
	
	
}